import { useDollarGet, useDollarPost } from "~/composables/useDollarFetchRequest";
import { objectToQueryString } from "~/utils/func";
import type { Response as GoodsDetailResponse } from "~/types/goods";

// 类型定义
interface DefaultTypeParams {
  [key: string]: any;
}

interface BuyerGoodsPageParams {
  pageNum?: number;
  pageSize?: number;
  [key: string]: any;
}

interface GetBuyerDetailParams {
  id: string | number;
}

interface CommentPageParams {
  pageNum?: number;
  pageSize?: number;
  goodsId?: string | number;
  saleUserId?: string | number;
  type?: number;
  [key: string]: any;
}

interface RecommendGoodsParams {
  goodsId: string | number;
  pageNum?: number;
  pageSize?: number;
  [key: string]: any;
}

interface AddShopCarParams {
  goodsId: string | number;
  quantity?: number;
  skuType?: number;
  [key: string]: any;
}

interface DeleteCarParams {
  goodsId?: string | number;
  skuType?: number;
  [key: string]: any;
}

interface ShopCarPageParams {
  pageNum?: number;
  pageSize?: number;
  [key: string]: any;
}

interface ShopIndexGoodsListParams {
  isAsc?: string;
  orderByColumn?: string;
  pageNum?: number;
  pageSize?: number;
  shopId: number;
}

// API 函数
export const defaultType = async (data: DefaultTypeParams) => useDollarPost('/api/skill/index/public/getRecommendType', data)
export const getAllType = async (data: DefaultTypeParams) => useDollarPost('/api/skill/index/public/getRecommendType', data)
export const buyerGoodsPage = async (data: BuyerGoodsPageParams) => useDollarPost('/api/skill/buyerGoods/buyerGoodsList', data)
export const getBuyerDetailById = async (data: GetBuyerDetailParams): Promise<GoodsDetailResponse> => useDollarGet('/api/skill/buyerGoods/buyerGoodsDetail?' + objectToQueryString(data))
export const commentPage = async (data: CommentPageParams) => useDollarPost('/api/msb/public/commentPage', data)
// 为你推荐
export const recommendGoods = async (data: RecommendGoodsParams) => useDollarPost('/api/msb/public/recommendGoods', data)
//添加到购物车 (参数: goodsId, quantity)
export const addShopCar = async (data: AddShopCarParams) => useDollarPost('/api/skill/shopCart/addShopCar', data)
//删除购物车
export const deleteCar = async (data: DeleteCarParams) => useDollarPost('/api/skill/shopCart/deleteCar', data)
//分页获取购物车列表
export const shopCarPage = async (data: ShopCarPageParams) => useDollarPost('/api/skill/shopCart/shopCarPage', data)
// 加价
export const confirmRiseOrder = async (data: any) => useDollarPost('/api/system/order/confirmRiseOrder', data)
// 查询加价订单支付状态
export const queryRiseStatus = async (data: any) => useDollarPost('/api/system/order/queryRiseStatus', data)
// 分页获取服务分类（旧接口）
export const serviceTypePage = async (data: any) => useDollarPost('/api/msb/type/page', data)
// 获取服务分类列表（新接口）
export const getServiceTypeList = async () => useDollarGet('/api/skill/buyerGoods/typeList')
// 买家获取热门服务
export const getHotService = async (data: any) => useDollarGet('/api/skill/index/public/getHotType?' + objectToQueryString(data))
// 如何工作视频
export const getWorkVideo = async (data: any) => useDollarPost('/api/msb/public/getWorkLink', data)
// 获取店铺主页商品列表
export const shopIndexGoodsList = async (data: ShopIndexGoodsListParams) => useDollarGet('/api/skill/buyerGoods/shopIndexGoodsList?' + objectToQueryString(data))
// 获取筛选中卖家级别用户数量
// export const getSalerLevelsCount = async (data: any) => useDollarPost('/api/msb/public/getSaleLevelCount', data)
